// <copyright file="GeekCode.cs" company="Alan Dean">
// The MIT License

// Copyright (c) 2008 Alan Dean

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// </copyright>
// <author>Alan Dean</author>
// <email>alan.dean@thoughtpad.net</email>

namespace Semantic.Rdf.Foaf
{
    using System;
    using System.Diagnostics.CodeAnalysis;
    using System.Runtime.Serialization;

    /// <summary>
    /// Represents a FOAF <see href="http://xmlns.com/foaf/spec/#term_geekcode">geekcode</see> property.
    /// <para>This class cannot be inherited.</para>
    /// </summary>
    /// 
    /// <remarks>
    /// <para>A textual geekcode for a person.</para>
    /// <para>
    /// The <see href="http://xmlns.com/foaf/spec/#term_geekcode">foaf:geekcode</see> property is used to represent a 'Geek Code'
    /// for some <see cref="T:Semantic.Rdf.Foaf.Person">foaf:Person</see>.
    /// </para>
    /// <para>
    /// See the <see href="http://www.geekcode.com/geek.html">Code of the Geeks</see> specification for details of the code,
    /// which provides a somewhat frivolous and willfully obscure mechanism for characterising technical expertise, interests and habits.
    /// The foaf:geekcode property is not bound to any particular version of the code.
    /// The last published version of the code was v3.12 in March 1996.
    /// </para>
    /// <para>
    /// As the <see href="http://www.geekcode.com/">Geek Code</see> website notes, the code played a small (but amusing) part in the history of the Internet.
    /// The foaf:geekcode property exists in acknowledgement of this history. It'll never be 1996 again.
    /// </para>
    /// <para>
    /// Note that the Geek Code is a densely packed collections of claims about the person it applies to;
    /// to express these claims explicitly in RDF/XML would be incredibly verbose.
    /// The syntax of the Geek Code allows for '&lt;' and '&gt;' characters, which have special meaning in RDF/XML.
    /// Consequently these should be carefully escaped in markup.
    /// </para>
    /// <para>
    /// See also the <see href="http://www.everything2.com/index.pl?node=GEEK%20CODE">geek code</see> entry
    /// in <see href="http://www.everything2.com/">everything2</see>, which tells us that the geek code originated in 1993;
    /// it was inspired (according to the inventor) by previous "bear", "smurf" and "twink" style-and-sexual-preference codes from lesbian and gay newsgroups.
    /// There is also a <see href="http://www.ebb.org/ungeek/">Geek Code Decoder Page</see>
    /// and a form-based <see href="http://www.joereiss.net/geek/geek.html">generator</see>.
    /// </para>
    /// </remarks>
    /// 
    /// <example>
    /// An example Geek Code:
    /// <code>
    /// GED/J d-- s:++>: a-- C++(++++) ULU++ P+ L++ E---- W+(-) N+++ o+ K+++ w--- O- M+ V-- PS++>$ PE++>$ Y++ PGP++ t- 5+++ X++ R+++>$ tv+ b+ DI+++ D+++ G++++ e++ h r-- y++**
    /// </code>
    /// ... would be written in FOAF RDF/XML as follows:
    /// <code>
    /// &lt;foaf:geekcode&gt;  GED/J d-- s:++&gt;: a-- C++(++++) ULU++ P+ L++ E---- W+(-) N+++ o+ K+++ w--- O- M+ V-- PS++&gt;$ PE++&gt;$ Y++ PGP++ t- 5+++ X++ R+++&gt;$ tv+ b+ DI+++ D+++ G++++ e++ h r-- y++** &lt;/foaf:geekcode&gt;
    /// </code>
    /// </example>
    /// 
    /// <seealso href="http://xmlns.com/foaf/spec/">
    /// FOAF Vocabulary Specification
    /// </seealso>
    /// <seealso href="http://www.geekcode.com/geek.html">
    /// The Code of the Geeks
    /// </seealso>
    [Serializable]
    public sealed class GeekCode : Triple
    {
        #region fields

        /// <summary>
        /// Stores the <see cref="P:Semantic.Rdf.Foaf.GeekCode.Predicate"/> data.
        /// </summary>
        private static readonly IUriReference _predicate = new UriReference("http://xmlns.com/foaf/0.1/geekcode");
        
        #endregion

        #region public GeekCode(Person, object)
        /// <overloads>
        /// Overloaded.
        /// Initializes a new instance of the <see cref="T:Semantic.Rdf.Foaf.GeekCode"/> class.
        /// </overloads>
        ///
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Semantic.Rdf.Foaf.GeekCode"/> class
        /// with the specified <paramref name="subject"/> and <paramref name="obj">object</paramref>.
        /// </summary>
        ///
        /// <param name="subject">The subject of the triple.</param>
        /// <param name="obj">The object of the triple.</param>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="subject"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public GeekCode(Person subject, object obj)
            : base((null == subject) ? null as IUriReference : subject.Subject, _predicate, obj)
        {
        }
        #endregion

        #region public GeekCode(IUriReference, object)
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Semantic.Rdf.Foaf.GeekCode"/> class
        /// with the specified <paramref name="subject"/> and <paramref name="obj">object</paramref>.
        /// </summary>
        ///
        /// <param name="subject">The subject of the triple.</param>
        /// <param name="obj">The object of the triple.</param>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="subject"/> is a <see langword="null"/> reference.<br/>-or-<br/>
        /// <paramref name="obj"/> is a <see langword="null"/> reference.
        /// </exception>
        [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "obj", Justification = "This is the appropriate naming.")]
        public GeekCode(IUriReference subject, object obj)
            : base(subject, _predicate, obj)
        {
        }
        #endregion

        #region private GeekCode(SerializationInfo, StreamingContext)
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Semantic.Rdf.Foaf.GeekCode"/> class
        /// from the specified instances of the <see cref="T:System.Runtime.Serialization.SerializationInfo"/>
        /// and <see cref="T:System.Runtime.Serialization.StreamingContext"/> classes.
        /// </summary>
        /// 
        /// <param name="info">
        /// An instance of the  <see cref="T:System.Runtime.Serialization.SerializationInfo"/> class
        /// containing the information required to serialize the
        /// new <see cref="T:Semantic.Rdf.BooleanLiteral"/> instance. 
        /// </param>
        /// <param name="context">
        /// An instance of the <see cref="T:System.Runtime.Serialization.StreamingContext"/> class
        /// containing the source of the serialized stream associated with the
        /// new <see cref="T:Semantic.Rdf.BooleanLiteral"/> instance.
        /// </param>
        /// 
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="info"/> is a <see langword="null"/> reference.
        /// </exception>
        private GeekCode(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }
        #endregion
    }
}